package com.huawei.chengdu.meetingdemo.view.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.huawei.chengdu.meetingdemo.R;
import com.huawei.chengdu.meetingdemo.presenter.ConfSdkPresenter;

public class IncomingCallDialog extends Dialog {
    private TextView incomingCallNum;
    private Button buttonCancel;
    private Button buttonAccept;

    public IncomingCallDialog(@NonNull Context context) {
        super(context);
        setContentView(R.layout.dialog_incoming_call);
        initView();
        initListener();
    }

    @Override
    public void show() {
        setCanceledOnTouchOutside(false);
        super.show();
    }

    private void initView() {
        incomingCallNum = findViewById(R.id.incoming_number);
        buttonCancel = findViewById(R.id.button_cancel);
        buttonAccept = findViewById(R.id.button_accept);
    }

    private void initListener() {
        buttonCancel.setOnClickListener((v -> {
            ConfSdkPresenter.refuseCall();
            dismiss();
        }));

        buttonAccept.setOnClickListener((v -> {
            ConfSdkPresenter.acceptCall();
            dismiss();
        }));
    }

    public void setIncomingCallNum (String callNum) {
        incomingCallNum.setText("来电人：" + callNum);
    }

}
